package com.carpedil.shirodemo.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.carpedil.shirodemo.system.model.RoleOperator;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/**
 * 角色-操作关系表 Mapper 接口
 *
 * @author carpedil
 * @since 2021-01-05
 */
@Repository
public interface RoleOperatorMapper extends BaseMapper<RoleOperator> {
  @Select("select operator_id from role_operator where role_id = #{roleId}")
  Integer[] getOperatorsByRoleId(@Param("roleId") Integer roleId);

  @Delete("delete from role_operator where role_id = #{roleId}")
  void deleteByRoleId(@Param("roleId") Integer roleId);

  /**
   * 插入角色操作权限
   *
   * @param roleId roleId
   * @param operatorIds operatorIds
   */
  void insertRoleOperators(
      @Param("roleId") Integer roleId, @Param("operatorIds") Integer[] operatorIds);
}
